package com.gqemf.controller;

import com.gqemf.entity.Emfhistory;
import com.gqemf.schedule.ScheduledTasks;
import com.gqemf.service.EmfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chan
 */
@RestController
public class EmfController {

    private ScheduledTasks scheduledTasks;

    private EmfService emfService;

    @Autowired
    public EmfController(ScheduledTasks scheduledTasks, EmfService emfService) {
        this.scheduledTasks = scheduledTasks;
        this.emfService = emfService;
    }

    @GetMapping("/csvfiles")
    public String requestReadAndWriteCsvFile(){
        scheduledTasks.readDataFile();
        return "execute readDataFile Function";
    }

    @GetMapping("/cleanbinfiles")
    public String clearBinFiles(){
        scheduledTasks.clearBinFiles();
        return "clear all of bin files ";
    }

    @GetMapping("/getemfhistories")
    public List<Emfhistory> getEmfHistories(){
        return emfService.getAllEmfHistories();
    }
}
